package ar.edu.unicen.pladema.ui.model.points;

public class AbstractPoint {
	private int y;
	private int x;
	public AbstractPoint(int px, int py) {
		this.y = py;
		this.x = px;
	}
	public int getY() {
		return y;
	}
	public void setY(int y) {
		this.y = y;
	}
	public int getX() {
		return x;
	}
	public void setX(int x) {
		this.x = x;
	}
	public void move(ScreenPoint from, ScreenPoint to) {
		if (this.equals(from)) {
			this.setY(to.getY());
			this.setX(to.getX());
		}
	}
	
	@Override
	public boolean equals(Object obj) {
		if (obj instanceof AbstractPoint) {
			AbstractPoint sp = (AbstractPoint) obj;
			return this.aceptX(sp.getX()) && this.aceptY(sp.getY());
		}
		// TODO Auto-generated method stub
		return super.equals(obj);
	}
	public boolean aceptX(int anX) {
		return (getX()+3>anX)&&(getX()-3<anX);
	}
	public boolean aceptY(int anY) {
		return (getY()+3>anY)&&(getY()-3<anY);
	}
	@Override
	public String toString() {
		return x+"-"+y;
	}
}
